package com.cs.composite;

import java.util.ArrayList;
import java.util.List;

/**
 * @author Sam.Lee E-mail:lishanman2007@163.com
 * @version Created：Aug 16, 2011 1:14:43 PM
 */
public class Composite extends Component {

	String name;

	List<Component> components = new ArrayList<Component>();

	public Composite(String name) {
		this.name = name;
	}

	public void add(Component component) {
		components.add(component);
	}

	public void printStruct(String prefix) {
		System.out.println(prefix + "+" + name);
		prefix += " ";
		for (Component component : components) {
			component.printStruct(prefix);
		}
	}

}
